// 公用样式初始样式
require("../../assets/css/index.less");
require("./player.less");
require("../../assets/fonts/iconfont.css");

// 引入工具函数
const dom = require('../../utils/dom')
const https = require('../../utils/https');
const local = require('../../utils/local');

dom.ready(function() {
    let id = location.search
        // console.log(id);
    let vDate = local.get('videoS')
    console.log(vDate);
    dom.getEle('video').src = 'http://fitness.h5.itsource.cn:3701' + vDate[0].videoUrl

    let flag = true
    let index = 0
    dom.addEvent('#playBtn', function() {
            if (flag) {
                dom.getEle('video').play()
                this.className = 'iconfont icon-zanting1'
            } else {
                dom.getEle('video').pause()
                this.className = "iconfont icon-youjiantou"
            }
            flag = !flag
        })
        //   下一节
    dom.addEvent('#nextBtn', function() {

            index++
            if (index >= vDate.length) {
                index = 0
            }

            dom.getEle('video').src = 'http://fitness.h5.itsource.cn:3701' + vDate[index].videoUrl
        })
        //上一节
    dom.addEvent('#backBtn', function() {
        index--
        if (index == -1) {
            index = vDate.length - 1
        }
        dom.getEle('video').src = 'http://fitness.h5.itsource.cn:3701' + vDate[index].videoUrl
    })
    dom.addEvent('.icon-zuojiantou', function() {
        location.href = 'train.html'
    })
})